'''
    统计目录大小的函数
'''
import os
def dir_size(dir1):
    size = 0
    dlist = os.listdir(dir1)
    for i in dlist:
        file1 = os.path.join(dir1,i)
        if os.path.isfile(file1):
            size = size + os.path.getsize(file1)
        else:
            dir_size(file1)
    return size